<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>代金券发送记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all"/>
    <link rel="stylesheet" href="../../css/news.css" media="all"/>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <form class="layui-form">
        <div class="layui-inline">
            <label class="layui-form-label">卡券编号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="code" placeholder="请输入卡券编号">
            </div>
        </div>
        <div class="layui-inline">
            <a class="layui-btn search_btn" lay-submit="" lay-filter="queryVoucher">查询</a>
        </div>

       <!-- <div class="layui-inline">
            <a class="layui-btn layui-btn-normal voucherPackagesAdd_btn">添加券包</a>
        </div>-->
    </form>

</blockquote>
<div class="layui-form news_list">
    <table class="layui-table" id="voucherList" lay-filter="voucherPackages"></table>
</div>
<div id="page"></div>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="plugins/layui/layui.js"></script>
<script type="text/html" id="barDemo">
   <!-- <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="iconfont icon-edit"></i>详情</a>
    <a class="layui-btn layui-btn-default layui-btn-xs" lay-event="sendVoucher"><i class="iconfont icon-edit"></i>发券</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"><i class="layui-icon"></i>删除</a>-->
</script>
<script type="text/javascript">
    layui.config({
        base: '/js/admin/'
    }).extend({
        ajaxExtention: 'ajaxExtention',//加载自定义扩展，每个业务js都需要加载这个ajax扩展
        $tool: 'tool'
    }).use(['table', 'form', '$tool'], function () {
        var table = layui.table;
            form = layui.form,
            $tool = layui.$tool;
        //方法级渲染
        var tableIns = table.render({
            elem: '#voucherList'
            , url: '/vouchers'
            , cols: [[
                {field: 'id', title: 'ID', fixed: true}
                , {field: 'title', title: '卡券标题'}
                , {field: 'code', title: '卡券编号'}
                , {field: 'amount', title: '卡券面值'}
                , {field: 'phone', title: '手机号'}
                , {field: 'dueTime', title: '到期时间'}
                , {field: 'isWriteoff', title: '核销状态',templet:function (d) {
                    if(d.isWriteoff==1){
                        return "已核销";
                    }else if(d.isWriteoff ==0){
                        return "未核销";
                    }
                }}
                ,{
                    field: 'writeOffTime', title: '核销时间', templet: function (d) {
                        if(d.writeOffTime != null){
                            return $tool.formatDate(d.createTime);
                        }else{
                            return "-------"
                        }

                }
                }
                , {
                    field: 'createTime', title: '创建时间', templet: function (d) {
                        return $tool.formatDate(d.createTime);
                    }
                }
            ]]
            , id: 'testReload'
            , page: true
        });

        form.on("submit(queryVoucher)", function (data) {
            var code = data.field.code;
            tableIns.reload({
                where: {
                    code: code
                }
            });
            return false;
        });
    });

</script>
</body>
</html>